<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html>
<html lang="zh">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<title>登录</title>

<meta name="description" content="User login page" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<link rel="stylesheet" href="lib/assets/css/bootstrap.css" />
<link rel="stylesheet" href="lib/assets/css/font-awesome.css" />

<link rel="stylesheet" href="lib/assets/css/ace-fonts.css" />

<link rel="stylesheet" href="lib/assets/css/ace.css" />

<script src="lib/assets/js/angular.min.js">
	
</script>
</head>

<base href="<%=basePath%>">
<%
	if (request.getAttribute("loginSuc") != null)
		response.sendRedirect("/system.html");
%>
<body class="login-layout light-login" data-ng-app="validationApp"
	data-ng-cloak>
	<div class="main-container">
		<div class="main-content">
			<div class="row">
				<div class="col-sm-10 col-sm-offset-1">
					<div class="login-container">
						<div class="center">
							<h1>
								<i class="ace-icon fa fa-leaf green"></i> <span class="red">工资</span>
								<span class="grey" id="id-text2">管理系统</span>
							</h1>
							<h4 class="blue" id="id-company-text">&copy;Group</h4>
						</div>

						<div class="space-6"></div>

						<div class="position-relative">
							<div id="login-box"
								class="login-box visible widget-box no-border"
								data-ng-controller="loginFormController">
								<div class="widget-body">
									<div class="widget-main">
										<h4 class="header blue lighter bigger">
											<i class="ace-icon fa fa-coffee green"></i> 请输入信息
										</h4>

										<div class="space-6"></div>

										<form name="loginForm"
											data-ng-submit="submitForm(loginForm.$valid)" novalidate>
											<fieldset>
												<label class="block clearfix"
													data-ng-class="{'has-error' : loginForm.username.$invalid && formIsSubmitted }">
													<span class="block input-icon input-icon-right"> <input
														type="text" name="username" class="form-control username"
														placeholder="用户名" data-ng-model="loginFormModel.username"
														required /> <i class="ace-icon fa fa-user"></i>
												</span> <%
 	if (request.getAttribute("userMsg") != null)
 		out.print(request.getAttribute("userMsg"));
 %>
													<p
														data-ng-show="loginForm.username.$invalid && formIsSubmitted"
														class="help-block" hidden>
														<i class="ace-icon fa fa-angle-up"></i><small>用户名未填写</small>
													</p>

												</label> <label class="block clearfix"
													data-ng-class="{'has-error' : loginForm.password.$invalid && formIsSubmitted}">
													<span class="block input-icon input-icon-right"> <input
														type="password" name="password"
														class="form-control password" placeholder="密码"
														data-ng-model="loginFormModel.password" required /> <i
														class="ace-icon fa fa-lock"></i>
												</span> <%
 	if (request.getAttribute("passMsg") != null)
 		out.print(request.getAttribute("passMsg"));
 %>
													<p
														data-ng-show="loginForm.password.$invalid && formIsSubmitted"
														class="help-block">
														<i class="ace-icon fa fa-angle-up"></i><small>密码未填写</small>
													</p>
												</label> <label class="block clearfix"
													data-ng-class="{'has-error' : loginForm.validationCode.$invalid && formIsSubmitted}">
													<span class="block input-icon input-icon-right"> <input
														type="text" name="validationCode"
														class="form-control validationCode" placeholder="验证码 "
														data-ng-model="loginFormModel.validationCode" required />
														<img alt="" src="index/checkCode"> <i
														class="ace-icon fa fa-lock"></i>
												</span> <%
 	if (request.getAttribute("checkCodeMsg") != null)
 		out.print(request.getAttribute("checkCodeMsg"));
 %> <%
 	if (request.getAttribute("errorMsg") != null)
 		out.print(request.getAttribute("errorMsg"));
 %>
													<p
														data-ng-show="loginForm.validationCode.$invalid && formIsSubmitted"
														class="help-block">
														<i class="ace-icon fa fa-angle-up"></i><small>验证码未填写</small>
													</p>
												</label>

												<div class="space"></div>

												<div class="clearfix">
													<label class="inline"> <input type="checkbox"
														class="ace" /> <span class="lbl"> 记住我</span>
													</label>

													<button type="submit"
														class="width-35 pull-right btn btn-sm btn-primary">
														<i class="ace-icon fa fa-key"></i> <span
															class="bigger-110">登录</span>
													</button>
												</div>

												<div class="space-4"></div>
											</fieldset>
										</form>
									</div>
									<!-- /.widget-main -->

									<div class="toolbar clearfix">
										<div>
											<a href="#" data-target="#forgot-box"
												class="forgot-password-link"> <i
												class="ace-icon fa fa-arrow-left"></i> 忘记密码
											</a>
										</div>

									</div>
								</div>
								<!-- /.widget-body -->
							</div>
							<!-- /.login-box -->

							<div id="forgot-box" class="forgot-box widget-box no-border"
								data-ng-controller="forgotFormController">
								<div class="widget-body">
									<div class="widget-main">
										<h4 class="header red lighter bigger">
											<i class="ace-icon fa fa-key"></i> 获取密码
										</h4>

										<div class="space-6"></div>
										<p>输入你的邮箱来获取重置密码链接</p>

										<form>
											<fieldset>
												<label class="block clearfix"> <span
													class="block input-icon input-icon-right"> <input
														type="email" class="form-control" placeholder="Email"
														required /> <i class="ace-icon fa fa-envelope"></i>
												</span>
												</label>

												<div class="clearfix">
													<button type="button"
														class="width-35 pull-right btn btn-sm btn-danger">
														<i class="ace-icon fa fa-lightbulb-o"></i> <span
															class="bigger-110">发送</span>
													</button>
												</div>
											</fieldset>
										</form>
									</div>
									<!-- /.widget-main -->

									<div class="toolbar center">
										<a href="#" data-target="#login-box"
											class="back-to-login-link"> 返回登录 <i
											class="ace-icon fa fa-arrow-right"></i>
										</a>
									</div>
								</div>
								<!-- /.widget-body -->
							</div>
							<!-- /.forgot-box -->

						</div>
						<!-- /.position-relative -->

					</div>
				</div>
				<!-- /.col -->
			</div>
			<!-- /.row -->
		</div>
		<!-- /.main-content -->
	</div>
	<!-- /.main-container -->

	<!-- basic scripts -->

	<!--[if !IE]> -->
	<script type="text/javascript">
		window.jQuery
				|| document.write("<script src='lib/assets/js/jquery.js'>"
						+ "<"
				+ "/script>");
	</script>

	<!-- <![endif]-->

	<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='lib/assets/js/jquery1x.js'>"+"<"+"/script>");
</script>
<![endif]-->
	<script type="text/javascript">
		if ('ontouchstart' in document.documentElement)
			document
					.write("<script src='lib/assets/js/jquery.mobile.custom.js'>"
							+ "<"
			+ "/script>");
	</script>

	<!-- inline scripts related to this page -->
	<script type="text/javascript">
		jQuery(function($) {
			$(document).on('click', '.toolbar a[data-target]', function(e) {
				e.preventDefault();
				var target = $(this).data('target');
				$('.widget-box.visible').removeClass('visible');//hide others
				$(target).addClass('visible');//show target
			});
		});

		var validationApp = angular.module('validationApp', []);

		validationApp.controller('loginFormController', function($scope) {
			$scope.formIsSubmitted = false;
			$scope.submitForm = function(isValid) { //check and submit
				//布尔变量指示表格是否提交过（是否点击过提交按钮）
				$scope.formIsSubmitted = true;
				//根据表格是否有效 进行操作
				if (isValid) {
					//alert('login success！');
					// TODO 提交表格内容请求
					var user_name = $(".username").val();
					var user_pass = $(".password").val();
					var user_check = $(".validationCode").val();

					var form = document.createElement("form");
					document.body.appendChild(form);

					var input = document.createElement("input");
					input.type = "text";
					input.name = "userName";
					input.value = user_pass;
					form.appendChild(input);

					var input2 = document.createElement("input");
					input2.type = "text";
					input2.name = "passWord";
					input2.value = user_name;
					form.appendChild(input2);

					var input3 = document.createElement("input");
					input3.type = "text";
					input3.name = "checkCode";
					input3.value = user_check;
					form.appendChild(input3);

					form.method = "POST";
					form.action = "userAccount/login";
					form.submit();
					document.body.removeChild(form);

				} else {
				}
			};
		});

		//为发送找回密码的那个表格准备的Controller，暂未使用
		validationApp.controller('forgotFormController', function($scope) {
			$scope.formIsSubmitted = false;
			$scope.submitForm = function(isValid) { //check and submit
				// check to make sure the form is completely valid
				$scope.formIsSubmitted = true;
				if (isValid) {
					alert('our form is amazing');//提交表格内容请求
				} else {
					alert("not valid.");//表格提交失败
				}
			};
		});
	</script>
</body>
</html>
